<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>Title</title>
    <script src="./js/vue.js"></script>
    <script src="./js/vue-router.js"></script>
    <style>
        .router-link-active {
            color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <router-link to="/home">home</router-link>
        <router-link to="/list">list</router-link>
        <router-link to="/news/10">news10</router-link>
        <router-link to="/news/20">news20</router-link>
        <router-link to="/news/30">news30</router-link>
        <router-view></router-view>
    </div>
    <script>
        let home = {
            template: `<div>home</div>`
        }
        let list = {
            template: "<div>list</div>"
        }
        let news = {
            props: {
                ids: String
            },
            template: "<div>news---{{ids}}----{{$route.params.ids}}</div>"
        }
        let router = new VueRouter({
            routes: [
                {
                    path: "/home",
                    component: home
                },
                {
                    path: "/list",
                    component: list
                },
                {
                    path: "/news/:ids",
                    component: news,
                    props: true
                }
            ]
        })
        let vm = new Vue({
            el: "#app",
            data: {
                msg: "vue"
            },
            methods: {},
            router
        });
    </script>
</body>
</html>